package core;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class Sqrt extends UnitAbstract{

	
	private double bias1 = 0.0;
	
	public Sqrt() {
		inputs = new String[]{"I",};
		outputs = new String[]{"O"};
	}
	
	public void read(DataPackage dataPack, String tPort) {
		
		for(int i=0; i<dataPack.data.length; i++){
			if(dataPack.data[i]==0){
				dataPack.data[i]=0;
			}else if(dataPack.data[i]<0){
				dataPack.data[i] = (- Math.sqrt(Math.abs(dataPack.data[i]))+ bias1);
			}else{
				dataPack.data[i] = (Math.sqrt(dataPack.data[i]))+bias1;
			}
		}
		sendData(dataPack);
			
	}

	
	@Override
	public String toString() {
		return "SQRT";
	}

	@Override
	public JFrame getFrame() {
		return null;
	}

	public double getBias1() {
		return bias1;
	}

	public void setBias1(double bias1) {
		this.bias1 = bias1;
	}
}
